package cn.edu.ujn.lab1.util;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
@Aspect
@Component
public class LogAspect {
	@Pointcut("execution(* cn.edu.ujn.lab1.dao.*.*(..))")
	public void myPointcut() {
		
	}
	@Before("myPointcut()")
	public void mybefore(JoinPoint jp) {
		System.out.println("日志输出：" +jp.getTarget()+":"+ jp.getSignature().getName());
	}
	@Around("myPointcut()")
	public Object myAround(ProceedingJoinPoint pjp) throws Throwable{
		System.out.println("【环绕前置通知】【"+ pjp.getSignature().getName()+"方法开始】");
		Object proceed = pjp.proceed();
		System.out.println("【环绕返回通知】【"+pjp.getSignature().getName()+"方法返回，返回值："+proceed+"】");
		return proceed;
	}

}
